import requestMeeting, { request } from '@/plugins/axios'
import { API_PROTAL_PREFIX } from '@/utils/constant'
import { FetchNoticeParam } from './interface'
/** 获取消息列表 */
export const fetchGetNotice = async () =>
	request<FetchNoticeParam>({
		baseURL: API_PROTAL_PREFIX,
		url: '/messages',
		method: 'get',
		params: { source: 'meeting' },
	}).then((res) => (res.success ? { data: res.list ?? [], total: res.total ?? 0 } : undefined))

/** 删除消息 */
export const fetchDeleteNotice = async (moids: string[]) =>
	requestMeeting({
		baseURL: API_PROTAL_PREFIX,
		url: '/messages/states',
		method: 'DELETE',
		data: { moids },
	}).then((res) => res.success)

/** 设置消息已读 */
export const fetchSetNoticeRead = async (moids: string[]) =>
	requestMeeting({
		baseURL: API_PROTAL_PREFIX,
		url: '/messages/states/read',
		method: 'PUT',
		data: { moids },
	}).then((res) => res.success)
